package com.css.fxfzysx.modules.vabStructure.controller;

import com.css.fxfzysx.base.response.RestResponse;
import com.css.fxfzysx.modules.cztDataMange.entity.CbcbInfoEntity;
import com.css.fxfzysx.modules.cztDataMange.entity.CbcpInfoEntity;
import com.css.fxfzysx.modules.vabStructure.param.CbcpInfoParam;
import com.css.fxfzysx.modules.vabStructure.service.PobStructureService;
import com.css.fxfzysx.util.PlatformObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 * 砖混结构
 */
@RestController
@RequestMapping("/pobStructure")
public class PobStructureController {

    @Autowired
    private PobStructureService pobStructureService;

    /**
     * 计算
     * map
     * cbcbiIds
     */
    @PostMapping("/countPobStructure")
    public RestResponse countPobStructure(@RequestBody Map<String, Object> map) {
        RestResponse restResponse = pobStructureService.countPobStructure(map);
        if (restResponse.getCode() == 200) {
            restResponse.setMessage("计算成功！");
        } else{
            restResponse.setMessage("计算失败！");
        }
        return restResponse;
    }
    /**
     * 计算
     */
    @PostMapping("/countPobStructure1")
    public RestResponse countPobStructure1(@RequestBody CbcpInfoParam cbcpInfoParam) {
        RestResponse restResponse = pobStructureService.countPobStructure1(cbcpInfoParam);
        if (restResponse.getCode() == 200) {
            restResponse.setMessage("计算成功！");
        } else{
            restResponse.setMessage("计算失败！");
        }
        return restResponse;
    }
    /**
     * 修改
     */
    @PostMapping("/updatePobStructure")
    public RestResponse updatePobStructure(@RequestBody  List<Map<String,Object>> cbcpInfoParam) {
        RestResponse restResponse = pobStructureService.updatePobStructure(cbcpInfoParam);
        if (restResponse.getCode() == 200) {
            restResponse.setMessage("修改成功！");
        } else {
            restResponse.setMessage("修改失败！");
        }
        return restResponse;
    }
    /**
     * 修改主表（建筑）的数据
     */
    @PostMapping("/updatePobStructure1")
    public RestResponse updatePobStructure1(@RequestBody  List<Map<String,Object>> cbcbInfoParam) {
        RestResponse restResponse = pobStructureService.updatePobStructure1(cbcbInfoParam);
        if (restResponse.getCode() == 200) {
            restResponse.setMessage("修改成功！");
        } else {
            restResponse.setMessage("修改失败！");
        }
        return restResponse;
    }
    /**
     * 修改子表（建筑的楼层）的数据
     */
    @PostMapping("/updatePobStructure2")
    public RestResponse updatePobStructure2(@RequestBody  List<Map<String,Object>> cbcbDetailParam) {
        RestResponse restResponse = pobStructureService.updatePobStructure2(cbcbDetailParam);
        if (restResponse.getCode() == 200) {
            restResponse.setMessage("修改成功！");
        } else {
            restResponse.setMessage("修改失败！");
        }
        return restResponse;
    }

    /**
     * 保存或修改
     */
    @PostMapping("/saveOrUpdatePobStructure")
    public RestResponse saveOrUpdatePobStructure(@RequestBody Map<String,Object> map) {
        return pobStructureService.saveOrUpdatePobStructure(map);
    }

    /**
     * 保存或修改
     */
    @PostMapping("/saveOrUpdatePobStructure1")
    public RestResponse saveOrUpdatePobStructure1(@RequestBody CbcpInfoParam cbcpInfoParam) {
        return pobStructureService.saveOrUpdatePobStructure1(cbcpInfoParam);
    }

    /**
     * 根据id查询
     */
    @GetMapping("/getById")
    public RestResponse getById(@RequestParam String id) {
        RestResponse restResponse = pobStructureService.getById(id);
        if (restResponse.getCode() == 200) {
            restResponse.setMessage("查询成功！");
        } else {
            restResponse.setMessage("查询失败！");
        }
        return restResponse;
    }
    /**
     * 根据id查询
     */
    @GetMapping("/getById1")
    public RestResponse getById1(@RequestParam String id) {
        RestResponse restResponse = pobStructureService.getById1(id);
        if (restResponse.getCode() == 200) {
            restResponse.setMessage("查询成功！");
        } else {
            restResponse.setMessage("查询失败！");
        }
        return restResponse;
    }

    /**
     * 砖混结构分页查询
     */
    @GetMapping("/queryPobStructure")
    public RestResponse queryPobStructure(CbcbInfoEntity cbcbInfoEntity, HttpServletRequest request) {
       return pobStructureService.queryPobStructure(cbcbInfoEntity,request);
    }
    /**
     * 砖混结构分页查询
     */
    @GetMapping("/queryPobStructure1")
    public RestResponse queryPobStructure1(CbcpInfoEntity cbcpInfoEntity, HttpServletRequest request) {
        return pobStructureService.queryPobStructure1(cbcpInfoEntity,request);
    }

    /**
     * 导出
     * @param cbcIds
     * @param response
     */
    @GetMapping("/exportPobStructure")
    public void exportPobStructure(String cbcIds, HttpServletResponse response){
        pobStructureService.exportPobStructure(cbcIds,response);
    }
    /**
     * 导出
     * @param cbcIds
     * @param response
     */
    @GetMapping("/exportPobStructure1")
    public void exportPobStructure1(String cbcIds, HttpServletResponse response){
        pobStructureService.exportPobStructure1(cbcIds,response);
    }
}
